<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib uri="/page" prefix="public"%>
<public:pageControl classPath="app.web.galgame.collects.GalGameEdit"/>
<script>

	function yuinyaBtn_click(form,page){
		
		var gameName = form.value("GAME_NAME");
		var gameNamePlus = form.value("GAME_NAME_PLUS");
		if(!Yacon.isEmpty(gameNamePlus)){
			gameName = gameName + "," + gameNamePlus;
		}
		
		Yacon.showModal({
			url: "netant/yuinyaGamePage.jsp?gameName="+gameName.encode(),
			height: "600px",
			width: "1200px",
			close: "yuinyaBtn_window_close"
		});
		
	}
	
	function yuinyaBtn_window_close(windows,page){
		
		var form = page.find("galgameEditForm");
		
		if(!Yacon.isEmpty(windows.returnValue)){
			var sendSet = new Yacon.data.DataSet(page);
			sendSet.setWhereField("gameID",windows.returnValue);
			sendSet.switchMessage("yuinyaSearch");
			if(sendSet.next()){
				
				//游戏简介
				var gameIntru = form.value("GAME_INTRU");
				if(Yacon.isEmpty(gameIntru)){
					form.value("GAME_INTRU",sendSet.getDataSetValue("GAME_MEMO"))
				}
				
				//游戏标签 - 去重
				var gameTags = form.value("GAME_TAGS");
				if(Yacon.isEmpty(gameTags)){
					form.value("GAME_TAGS",sendSet.getDataSetValue("GAME_TYP").replaceAll(" ",","));
				}else{
					gameTags += ","+  sendSet.getDataSetValue("GAME_TYP").replaceAll(" ",",");
					var newSet = new Yacon.data.DataSet(page);
					newSet.setWhereField("gameTags",gameTags.encode())
					newSet.switchMessage("tagsClear");
					var tags = newSet.getDataValue().decode();
					if(tags != ""){
						tags = tags.substring(1);
					}
					form.value("GAME_TAGS",tags);
				}
				
				//厂商名称
				var gameFact = form.value("GAME_FACTORY");
				if(Yacon.isEmpty(gameFact)){
					form.value("GAME_FACTORY",sendSet.getDataSetValue("GAME_PRO"))
				}
				
				//发布时间
				var gameDate = form.value("GAME_PRO_TIME");
				if(Yacon.isEmpty(gameDate) && Yacon.isEmpty(gameDate.trim()) ){
					form.value("GAME_PRO_TIME",sendSet.getDataSetValue("GAME_DATE"))
				}
				
				//游戏名称
				var gameNamePlus = form.value("GAME_NAME_PLUS");
				var gameName = sendSet.getDataSetValue("GAME_NAME");
				if(Yacon.isEmpty(gameNamePlus)){
					form.value("GAME_NAME_PLUS",gameName);
				}else{
					gameNamePlus += ","+  gameName;
					var newSet = new Yacon.data.DataSet(page);
					newSet.setWhereField("gameTags",gameNamePlus.encode())
					newSet.switchMessage("tagsClear");
					var tags = newSet.getDataValue().decode();
					if(tags != ""){
						tags = tags.substring(1);
					}
					form.value("GAME_NAME_PLUS",tags);
				}
				
				//游戏类型
				var tagNew = form.value("GAME_TAGS").toUpperCase();
				var type = "ADV";
				if(tagNew.indexOf("RPG")>-1){
					type += ","+ "RPG";
				}
				if(tagNew.indexOf("SLG")>-1){
					type += ","+ "SLG";
				}
				
				if(tagNew.indexOf("ACT")>-1){
					type += ","+ "FST";
				}
				
				if(tagNew.indexOf("TAL")>-1){
					type += ","+ "TCG";
				}
				form.check("GAME_TYP",type);
				
				if(tagNew.indexOf("3D")>-1){
					form.radio("GAME_VISUAL","02");
				}
				
				
			}
		}
		
	}

	function sadBrotherBtn_click(form,page){
		
		var gameName = form.value("GAME_NAME");
		var gameNamePlus = form.value("GAME_NAME_PLUS");
		if(!Yacon.isEmpty(gameNamePlus)){
			gameName = gameName + "," + gameNamePlus;
		}
		
		Yacon.showModal({
			url: "netant/sadBrotherPage.jsp?gameName="+gameName.encode(),
			height: "600px",
			width: "1200px",
			close: "sadBrotherBtn_window_close"
		});
		
	}
	
	function sadBrotherBtn_window_close(windows,page){
		
		var form = page.find("galgameEditForm");
		
		if(!Yacon.isEmpty(windows.returnValue)){
			var sendSet = new Yacon.data.DataSet(page);
			sendSet.setWhereField("gameID",windows.returnValue);
			sendSet.switchMessage("sadBrotherSearch");
			if(sendSet.next()){
				
				//游戏简介
				var gameIntru = form.value("GAME_INTRU");
				if(Yacon.isEmpty(gameIntru)){
					form.value("GAME_INTRU",sendSet.getDataSetValue("LEO_GAL_MEMO"))
				}
				
				//游戏备注
				var gameMemo = form.value("GEME_MEMO");
				if(Yacon.isEmpty(gameMemo)){
					form.value("GEME_MEMO",sendSet.getDataSetValue("LEO_GAL_REMARK"))
				}
				
			}
		}
		
	}
	
	function hgameCNBtn_click(form,page){
		
		var gameName = form.value("GAME_NAME");
		var gameNamePlus = form.value("GAME_NAME_PLUS");
		if(!Yacon.isEmpty(gameNamePlus)){
			gameName = gameName + "," + gameNamePlus;
		}
		
		Yacon.showModal({
			url: "netant/hgamecnPage.jsp?gameName="+gameName.encode(),
			height: "600px",
			width: "1200px",
			close: "hgameCNBtn_window_close"
		});
		
	}
	
	function hgameCNBtn_window_close(windows,page){
		
		var form = page.find("galgameEditForm");
		
		if(!Yacon.isEmpty(windows.returnValue)){
			var sendSet = new Yacon.data.DataSet(page);
			sendSet.setWhereField("gameID",windows.returnValue);
			sendSet.switchMessage("hgameCNSearch");
			if(sendSet.next()){
				
				//游戏简介
				var gameIntru = form.value("GAME_INTRU");
				if(Yacon.isEmpty(gameIntru)){
					form.value("GAME_INTRU",sendSet.getDataSetValue("GAME_MEMO"))
				}
				
				//游戏标签 - 去重
				var gameTags = form.value("GAME_TAGS");
				if(Yacon.isEmpty(gameTags)){
					form.value("GAME_TAGS",sendSet.getDataSetValue("GAME_TAG").replaceAll(" ",","));
				}else{
					gameTags += ","+  sendSet.getDataSetValue("GAME_TAG").replaceAll(" ",",");
					var newSet = new Yacon.data.DataSet(page);
					newSet.setWhereField("gameTags",gameTags.encode())
					newSet.switchMessage("tagsClear");
					var tags = newSet.getDataValue().decode();
					if(tags != ""){
						tags = tags.substring(1);
					}
					form.value("GAME_TAGS",tags);
				}
				
				//厂商名称
				var gameFact = form.value("GAME_FACTORY");
				if(Yacon.isEmpty(gameFact)){
					form.value("GAME_FACTORY",sendSet.getDataSetValue("GAME_FACTORY"))
				}
				
				//发布时间
				var gameDate = form.value("GAME_PRO_TIME");
				if(Yacon.isEmpty(gameDate) && Yacon.isEmpty(gameDate.trim()) ){
					form.value("GAME_PRO_TIME",sendSet.getDataSetValue("GAME_DATE"))
				}
				
				//游戏名称
				var gameNamePlus = form.value("GAME_NAME_PLUS");
				var gameName = sendSet.getDataSetValue("GAME_NAME");
				var gameNameOth = sendSet.getDataSetValue("GAME_NAME_OTH");
				if(!Yacon.isEmpty(gameNameOth)){
					gameName += ","+ gameNameOth;
				}
				if(Yacon.isEmpty(gameNamePlus)){
					form.value("GAME_NAME_PLUS",gameName);
				}else{
					gameNamePlus += ","+  gameName;
					var newSet = new Yacon.data.DataSet(page);
					newSet.setWhereField("gameTags",gameNamePlus.encode())
					newSet.switchMessage("tagsClear");
					var tags = newSet.getDataValue().decode();
					if(tags != ""){
						tags = tags.substring(1);
					}
					form.value("GAME_NAME_PLUS",tags);
				}
				
				//游戏类型
				var tagNew = form.value("GAME_TAGS").toUpperCase();
				var type = "ADV";
				if(tagNew.indexOf("RPG")>-1){
					type += ","+ "RPG";
				}
				if(tagNew.indexOf("SLG")>-1){
					type += ","+ "SLG";
				}
				
				if(tagNew.indexOf("ACT")>-1){
					type += ","+ "FST";
				}
				
				if(tagNew.indexOf("TAL")>-1){
					type += ","+ "TCG";
				}
				form.check("GAME_TYP",type);
				
				if(tagNew.indexOf("3D")>-1){
					form.radio("GAME_VISUAL","02");
				}
			}
		}
		
	}
	
	function bangumiBtn_click(form,page){
		
		var gameName = form.value("GAME_NAME");
		var gameNamePlus = form.value("GAME_NAME_PLUS");
		if(!Yacon.isEmpty(gameNamePlus)){
			gameName = gameName + "," + gameNamePlus;
		}
	
		Yacon.showModal({
			url: "netant/bangumiGamePage.jsp?gameName="+gameName.encode(),
			height: "600px",
			width: "1200px",
			close: "bangumiBtn_window_close"
		});
		
	}
	
	function bangumiBtn_window_close(windows,page){
		
		var form = page.find("galgameEditForm");
		
		if(!Yacon.isEmpty(windows.returnValue)){
			var sendSet = new Yacon.data.DataSet(page);
			sendSet.setWhereField("gameID",windows.returnValue);
			sendSet.switchMessage("bangumiSearch");
			if(sendSet.next()){
				
				//游戏简介
				var gameIntru = form.value("GAME_INTRU");
				if(Yacon.isEmpty(gameIntru)){
					form.value("GAME_INTRU",sendSet.getDataSetValue("GAME_MEMO"))
				}
				
				//游戏标签 - 去重
				var gameTags = form.value("GAME_TAGS");
				if(Yacon.isEmpty(gameTags)){
					form.value("GAME_TAGS",sendSet.getDataSetValue("GAME_TAG"));
				}else{
					gameTags += ","+ sendSet.getDataSetValue("GAME_TAG");
					var newSet = new Yacon.data.DataSet(page);
					newSet.setWhereField("gameTags",gameTags.encode())
					newSet.switchMessage("tagsClear");
					var tags = newSet.getDataValue().decode();
					if(tags != ""){
						tags = tags.substring(1);
					}
					form.value("GAME_TAGS",tags);
				}
				
				//厂商名称
				var gameFact = form.value("GAME_FACTORY");
				if(Yacon.isEmpty(gameFact)){
					form.value("GAME_FACTORY",sendSet.getDataSetValue("GAME_MAKER"));
				}
				
				//发布时间
				var gameDate = form.value("GAME_PRO_TIME");
				if(Yacon.isEmpty(gameDate) && Yacon.isEmpty(gameDate.trim()) ){
					form.value("GAME_PRO_TIME",sendSet.getDataSetValue("GAME_DATE"));
				}
				
				//游戏名称
				var gameNamePlus = form.value("GAME_NAME_PLUS");
				var gameName = sendSet.getDataSetValue("GAME_NAME");
				var gameNameOth = sendSet.getDataSetValue("GAME_NAME_OTH");
				if(!Yacon.isEmpty(gameNameOth)){
					gameName += ","+gameNameOth;
				}
				if(Yacon.isEmpty(gameNamePlus)){
					form.value("GAME_NAME_PLUS",gameName);
				}else{
					gameNamePlus += ","+  gameName;
					var newSet = new Yacon.data.DataSet(page);
					newSet.setWhereField("gameTags",gameNamePlus.encode())
					newSet.switchMessage("tagsClear");
					var tags = newSet.getDataValue().decode();
					if(tags != ""){
						tags = tags.substring(1);
					}
					form.value("GAME_NAME_PLUS",tags);
				}
				
				//游戏类型
				var tagNew = form.value("GAME_TAGS").toUpperCase();
				var type = "ADV";
				if(tagNew.indexOf("RPG")>-1){
					type += ","+ "RPG";
				}
				if(tagNew.indexOf("SLG")>-1){
					type += ","+ "SLG";
				}
				
				if(tagNew.indexOf("ACT")>-1){
					type += ","+ "FST";
				}
				
				if(tagNew.indexOf("TAL")>-1){
					type += ","+ "TCG";
				}
				form.check("GAME_TYP",type);
				
			}
		}
		
	}
</script>